﻿using LD.Host;
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Linq;

namespace LD
{
    public class PlcCommManger
    {
        private static PlcCommManger instance;
        private static object locker = new object();
        private string _filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"Config\\PlcCommManger.config");
        private PlcCommManger()
        {
        }

        public static PlcCommManger Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (locker)
                    {
                        if (instance == null)
                            instance = new PlcCommManger();
                    }
                }
                return instance;
            }
        }

        public List<ScrewAdr> PLCScrewAdrs { get; set; }
        public List<DoorLock> DoorLocks { get; set; }
        public WipAdr WipAdr { get; set; }
        /// <summary>
        /// 加载json
        /// </summary>
        public void Load()
        {
            instance = JsonSerializeHelper.Load<PlcCommManger>(_filePath);
        }

        public void Save()
        {
            JsonSerializeHelper.Save(this, _filePath);
        }
    }
}


